﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ExtAspNet;
using System.Data;

namespace HY.WEB.SA
{
    public partial class schedu_add : PageBase
    {
        public string us,um,tab="sch_edu";
        protected void Page_Load(object sender, EventArgs e)
        {
            us = Session["ID"].ToString();
            um = Session["user"].ToString();
            if (!IsPostBack)
            {
                if (!String.IsNullOrEmpty(Request["stype"]))
                {
                     hidstype.Text = Request["sid"].Trim();                
                }

                if (!String.IsNullOrEmpty(Request["schbh"]))
                {
                    hidsch.Text = Request["schbh"].Trim();
                } 

                Fill();
            }       
        }
 
       void Fill()
        {
            DataTable e;
            //岗位分类
            e = BLL.Bllbase.get_table("[school]");
            ddlschool.Items.Clear();
            for (int i = 0; i < e.Rows.Count; i++)
            {
                ddlschool.Items.Add(new ExtAspNet.ListItem(e.Rows[i]["schname"].ToString().Trim(), e.Rows[i]["schbh"].ToString().Trim()));
            }
            ddlschool.DataBind();

            if (hidsch.Text != "")     //学校    
                ddlschool.SelectedIndex = ddlschool.Items.IndexOf(ddlschool.Items.FindByValue(hidsch.Text));

        }
  
        

        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            Model.SC.sch_edu jb = new Model.SC.sch_edu();

          jb.ebh = BLL.BllAutoCode.GetMaxBH("sch_edu"); //岗位编号
          if (jb.ebh == "") return;

          jb.schbh = ddlschool.SelectedValue;
          jb.schname =ddlschool.SelectedText;
            
          jb.spro = txtpro.Text; 

          jb.fnum =int.Parse(txtf.Text);
          jb.mnum = int.Parse(txtm.Text);
          jb.snum = jb.fnum + jb.mnum;
          jb.fyear = txtyear.Text;
          jb.memo = txtmemo.Text;

              if (string.IsNullOrEmpty(date1.Text.Trim()))
                 date1.Text = "1900-01-01";

              if (string.IsNullOrEmpty(date2.Text.Trim()))
                  date2.Text = "1900-01-01";

           jb.sdate=DateTime.Parse(date1.Text.Trim());

           jb.edate = DateTime.Parse(date2.Text.Trim());

           jb.stype = ddltype.SelectedValue;
            

            BLL.SC.sch_edu sco = new BLL.SC.sch_edu();
             sco.Add(jb);


             //更新业务员操作记录
             BLL.Bllbase.update_rec(tab, um, " ebh='" + jb.ebh + "' ");


            Alert.Show("添加完成 ");
            PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
           // PageContext.RegisterStartupScript(ActiveWindow.GetWriteBackValueReference(hidstype.Text) + ActiveWindow.GetHidePostBackReference());
        }

       
    }
}